<template>
  <el-dialog :title="title || ''" :visible.sync="show" :width="width || '30%'" :append-to-body="true">
    <slot></slot>
    <span slot="footer">
      <el-button @click="handlleCancel" size="small">取消</el-button>
      <el-button
        type="primary"
        :disabled="loading"
        @click="handleConfrim"
        size="small"
        >确认</el-button
      >
    </span>
  </el-dialog>
</template>


<script>
export default {
  props: ["width", "title"],
  data() {
    return {
      show: false,
      loading: false,
    };
  },
  methods: {
    close() {
      this.show = false;
    },
    open() {
      this.show = true;
    },
    handleConfrim() {
      this.loading = true;
      setTimeout(() => {
        this.loading = false;
      }, 300);
      this.$emit("handleConfrim");
      this.close()
    },
    handlleCancel() {
      this.$emit("handlleCancel");
      this.close()
    },
  },
};
</script>